<template>
	<view class=" bg-white">
		<view class="cu-list menu" >
			<view class="cu-item ">
				<view class="content padding-tb-sm">
					<view class="flex">
						反馈类型：<DictTag :options="feedbackTypeOptions" :value="feedback.feedbackType" />
					</view>
					<view class="flex">
						反馈标题：{{feedback.feedbackTitle}}
					</view>
					<view class="flex">
						反馈内容：{{feedback.feedbackContent}}
					</view>
					<view class="flex">
						<u-image v-for="(item, index) in picList" :src="item" width="80px" height="80px"></u-image>
					</view>
					<view class="flex">
						反馈时间：{{feedback.createTime}}
					</view>
					<view class="flex">
						回复内容：{{feedback.replyContent}}
					</view>
					<view class="flex">
						回复时间：{{feedback.replyTime == null ? '' : feedback.replyTime}}
					</view>
				</view>
				<view class="action">
					<view class="cu-tag badge bg-white margin">
						<DictTag :options="feedbackStatusOptions" :value="feedback.feedbackStatus"/>
					</view>
				</view>
			</view>
		</view>
		<view class="padding flex flex-direction margin-top" v-if="feedback.feedbackStatus == 0">
			<button class="cu-btn bg-green lg cuIcon-edit" @click="gotoEdit()">编辑反馈内容</button>
			<button class="cu-btn bg-red margin-tb-sm lg cuIcon-delete" @click="delFeedback()">删除反馈内容</button>
		</view>
	</view>
</template>

<script>
	
	import { feedbackDetail, feedbackDel } from '@/api/cms.js';
	import { getDictData } from '@/api/api.js';
	
	export default {
		data() {
			return {
				id: 0,
				feedback: {},
				
				feedbackTypeOptions: [], // 反馈类型选项
				feedbackStatusOptions: [], // 反馈状态选项
				
				picList: [],
			}
		},
		onLoad(options) {
			this.id = options.id;
			this.getDictData();
		},
		onShow() {
			this.getFeedbackDetail();
		},
		methods: {
			
			// 跳转反馈编辑
			gotoEdit() {
				uni.$u.route({
					url: 'pages/mine/feedback/feedbackContent',
					params: {
						id: this.id
					}
				})
			},
			
			// 获取反馈详情
			getFeedbackDetail() {
				feedbackDetail({
					feedbackId: this.id
				}).then(res => {
					this.picList = res.data.feedbackAttach === "" ? [] : res.data.feedbackAttach.split(",");
					this.feedback = res.data;
				})
			},
			
			// 删除反馈内容
			delFeedback() {
				feedbackDel({
					feedbackId: this.id
				}).then(res => {
					this.$util.$navigateBack(res.msg)
				})
			},
			
			// 获取字典数据
			getDictData() {
				getDictData({
					dictType: "cms_feedback_type"
				}).then(res => {
					this.feedbackTypeOptions = res.data;
				})
				
				getDictData({
					dictType: "cms_feedback_status"
				}).then(res => {
					this.feedbackStatusOptions = res.data;
				})
			},
		}
	}
</script>

<style>

</style>
